<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<c:set var="ctx" value=" ${pageContext.request.contextPath}" />
<html>
<head>
<title>审计缺陷</title>
<script type="text/javascript">
	var $grid;
	var grid;

	$(function() {
		$grid = $("#grid").datagrid($.extend({},datagridOption, {
			url : "${ctx}/fnd/auditDefect/dataGrid?businessKey=${param.businessKey}",
			//fitColumns : true,
			nowrap:false,
		    columns : [ [  {
				field : 'ck',
				checkbox : true
			}, {
				field : 'auditProDtl.auditPro.auditName',
				title : '项目名称',
				width : 150,
				sortable : true,
				styler:function(value, row, index){
					if(row.status==1){
						return 'background-color:#eef3f8;';
					}else{
						return "";
					}
					
				}
			}, {
				field : 'auditProDtl.auditFinding',
				title : '审计监察法务发现问题',
				width : 400,
				sortable : true,
				formatter: function (value) {
					if(value)
		               return "<span title='" + value + "'>" + value + "</span>";
		        }
			}, {
				field : 'auditProDtl.auditSuggestion',
				title : '审计监察法务建议',
				width : 400,
				sortable : true,
				formatter: function (value) {
					if(value)
		               return "<span title='" + value + "'>" + value + "</span>";
		        }
			}, {
				field : 'nkfl',
				title : '内控分类',
				width : 100,
				sortable : true
			}, {
				field : 'qxlb',
				title : '缺陷类别',
				width : 100,
				sortable : true
			}, {
				field : 'qxyxfl',
				title : '缺陷影响分类',
				width : 100,
				sortable : true
			}, {
				field : 'qxlh',
				title : '缺陷量化',
				width : 100,
				sortable : true
			}, {
				field : 'whcd',
				title : '危害程度',
				width : 100,
				sortable : true
			}, {
				field : 'kncd',
				title : '可能程度',
				width : 100,
				sortable : true
			}, {
				field : 'gzcd',
				title : '关注程度',
				width : 100,
				sortable : true
			}, {
				field : 'qxrd',
				title : '缺陷认定',
				width : 100,
				sortable : true
			}, {
				field : 'qxyygl',
				title : '缺陷原因归类',
				width : 100,
				sortable : true
			}, {
				field : 'dwcj',
				title : '单位层级',
				width : 100,
				sortable : true
			}, {
				field : 'zgqk',
				title : '整改情况',
				width : 100,
				sortable : true
			}, {
				field : 'zgtd',
				title : '整改态度',
				width : 100,
				sortable : true
			}, {
				field : 'wtlb',
				title : '问题类别',
				width : 100,
				sortable : true
			} , {
				field : 'wtyzcd',
				title : '问题严重程度',
				width : 100,
				sortable : true
			}, {
				field : 'syfxkjscd',
				title : '剩余风险可接受程度',
				width : 100,
				sortable : true
			}, {
				field : 'dyxz',
				title : '动因性质',
				width : 100,
				sortable : true
			},{
				field : 'lastUpdateBy.trueName',
				title : '修改人',
				width : 100,
				sortable : true
			},{
				field : 'lastUpdateTime',
				title : '修改时间',
				width : 100,
				sortable : true
			}] ],
			onDblClickRow : function(index, rowData) {
				$.isFunction(fn_edit) && fn_edit.call(this, rowData);
			} 
		}));
		
		$grid.datagrid('enableFilter', [ buildDGFilterYesOrNoFieldOptions($grid, 'enable') ]);
		
	     $("#add").click(function() {
			$("#fm").form("clear");
			$('#fm').form('load', {
				"auditProDtl" :'${param.businessKey}'
			});
			$("#dlg").dialog("open").dialog("setTitle", "新增审计缺陷表").dialog("maximize");
			$("#dlg-btn").show();
		});
	     
	     fn_initComboNotId("nkfl", "nkfl", false);
	     fn_initComboNotId("qxyxfl", "qxyxfl", false);
	     fn_initComboNotId("gzcd", "gzcd", false);
	     fn_initComboNotId("zgqk", "zgqk", false);
	     fn_initComboNotId("zgtd", "zgtd", false);
	     fn_initComboNotId("wtlb", "wtlb", false);
	     fn_initComboNotId("wtyzcd", "wtyzcd", false);
	     fn_initComboNotId("syfxkjscd", "syfxkjscd", false);
	     fn_initComboNotId("dyxz", "dyxz", false);
	     fn_initComboNotId("qxlb", "qxlb", false);
	     fn_initComboNotId("qxrd", "qxrd", false);
	     fn_initComboNotId("qxyygl", "qxyygl", false);
	     
	     
	     
	     
		$("#edit").click(function() {
			var rowData = $grid.datagrid("getSelected");
			if (!rowData) {
				showInfo("您未选中行，无法编辑");
			} else {
				fn_edit(rowData);
			}
		});
		
		//excel导入
		$("#excelImport").click(function() {
			$.easyui.importor.showImportor({
				importNo : "auditDefect",
				onExportSuccess : function(file, data) {
					$grid.datagrid('load');
				}
			});
		});
		
		$("#delete").click(function() {
			multiDeleteDataGrid($grid, "${ctx}/fnd/auditDefect/multiDelete");
		});
		$("#search").click(function() {
			$grid.datagrid('load', $("#tt").form("getData"));
		});
		$("#excelExport").click(function() {
			var url = "${ctx}/fnd/auditDefect/excelExport?" + $.param($grid.datagrid('options').queryParams);
			if ($grid.datagrid("options").filterRules) {
				url += "&filterRules=" + JSON.stringify($grid.datagrid("options").filterRules);
			}
			window.parent.location.href = url;
		});
		 
	});
	 
	function fn_edit(rowData) {
		var isEdit="${isEdit}";
		if(isEdit=="1"){			
			$("#dlg").dialog("open").dialog("setTitle", "编辑审计缺陷").dialog("maximize");
			$("#dlg-btn").show();
		}else{
			$("#dlg").dialog("open").dialog("setTitle", "查看审计缺陷").dialog("maximize");
			$("#dlg-btn").hide();
		}
			
			
			$("#fm").form("clear");
			$("#fm").form("load", $.extend({},rowData,{
				"auditProDtl" :rowData.auditProDtl.id
			}));
			$("#auditFinding").html(rowData.auditProDtl.auditFinding);
			$("#auditSuggestion").html(rowData.auditProDtl.auditSuggestion);
	}
 
	//打印功能的实现
	<shiro:hasPermission name="company:print">
	   function fun_print()
	   {
		   printDataGrid($grid, "${ctx}/fnd/auditDefect/print?ids=");
	   }
	   function printDataGrid($grid, printUrl, operName) {
			var rows = $grid.datagrid('getChecked');
			var ids = "";
			if (rows) {
				$.each(rows, function(index, value) {
					ids += (value.id + ",")
				});
				if (ids == "") {
					$.messager.alert("操作提醒", "请先勾选需要打印的记录", "warning");
				} else {
					$.messager.confirm("您确定要打印勾选的" + rows.length + "条记录吗？", function(c) {
						if (c) {
							window.open(printUrl+ids, "_blank");//重新打开 
						}
					});
				}
			} else {
				$.messager.alert("操作提醒", "请先勾选需要打印的记录", "warning");
			}
		}
	   </shiro:hasPermission>
	
</script>
</head>

<body>
	<div data-options="region:'center',fit:true,border:false">
		<table id="grid">
		</table>
	</div>
	<div id="tt" class="row">
		 
		<div class="col-md-12">
			<c:if test="${isEdit==1}"> 
			  	<c:if test="${not empty param.taskId}">
						<!-- <button id="add" type="button" class="btn btn-primary">
							<span class="glyphicon glyphicon-plus"></span> 新增
						</button>				
						<button id="delete" type="button" class="btn btn-danger">
							<span class="glyphicon glyphicon-minus"></span> 删除
						</button> -->
		 		</c:if>
		 		
			 </c:if>
			<button id="edit" type="button" class="btn btn-primary">
					<span class="glyphicon glyphicon-pencil"></span> 编辑
				</button>
				
			<shiro:hasPermission name="auditDefect:export">
				<button id="excelExport" type="button" class="btn btn-primary">
					<span class="glyphicon glyphicon-open"></span> Excel导出
				</button>
			</shiro:hasPermission>
			<span style="float:right;padding:8px 0 0 0;color:red;">双击行或点击“编辑 ”按钮，可打开窗口编辑详细数据</span>		 
		</div>
	</div>

		<div id="dlg" class="easyui-dialog" style="width: 720px; height: 665px; padding: 10px 20px"
			data-options="resizable:true,modal:true, buttons:'#dlg-btn',closed:true">
			<form id="fm" method="post">
		<input type="hidden" name="id" />
<input type="hidden" name="auditProDtl" />   
				<table id="tbl">
					<tr>
						<td><label>整改发现:</label></td>
					</tr>
			    	<tr>
						<td colspan="3"><div id="auditFinding" style="width:800px;overflow: auto;border:1px solid #000;padding: 10px;" >${auditFinding}</div></td>
					</tr>
			    	<tr>
						<td><label>整改建议:</label></td>
					</tr>
			    	<tr>
						<td colspan="3"><div id="auditSuggestion" style="width:800px;overflow: auto;border:1px solid #000;padding: 10px;" >${auditSuggestion}</div></td>
					</tr>					
					<tr>
						<td><label>内控分类:</label></td>
						<td ><input id="nkfl" name="nkfl" class="easyui-validatebox" data-options=""></td>
						<td><label>缺陷类别:</label></td>
						<td ><input id="qxlb" name="qxlb" class="easyui-validatebox" data-options=""></td>
					</tr>
					
					<tr>
						<td><label>缺陷影响分类:</label></td>
						<td ><input id="qxyxfl" name="qxyxfl" class="easyui-validatebox" data-options=""></td>
						<td><label>缺陷量化(具体金额):</label></td>
						<td ><input name="qxlh" class="easyui-validatebox" data-options=""></td>
						
					</tr>
					<tr>
						<td><label>危害程度（1-5,1为最低）:</label></td>
						<td ><input name="whcd" class="easyui-numberbox" data-options="max:5,min:1"></td>
						<td><label>可能程度（1-5,1为最低）:</label></td>
						<td ><input name="kncd" class="easyui-numberbox" data-options="max:5,min:1"></td>
						
					</tr>
					<tr>
						<td><label>关注程度:</label></td>
						<td ><input id="gzcd" name="gzcd" class="easyui-validatebox" data-options=""></td>
						<td><label>缺陷认定:</label></td>
						<td ><input id="qxrd" name="qxrd" class="easyui-validatebox" data-options=""></td>
						
					</tr>
					<tr>
						<td><label>缺陷原因归类:</label></td>
						<td ><input id="qxyygl" name="qxyygl" class="easyui-validatebox" data-options=""></td>
						<td><label>单位层级（1-4，1为宝钢集团、2为韶关钢铁，3为韶关钢铁一级子公司，4为韶关钢铁二级子公司）:</label></td>
						<td ><input name="dwcj" class="easyui-numberbox" data-options="max:4,min:1"></td>

					</tr>
					<tr>
						<td><label>整改情况:</label></td>
						<td ><input id="zgqk" name="zgqk" class="easyui-validatebox" data-options=""></td>
						<td><label>整改态度:</label></td>
						<td ><input id="zgtd" name="zgtd" class="easyui-validatebox" data-options=""></td>
					</tr>
					<tr>
						<td><label>问题类别:</label></td>
						<td ><input id="wtlb" name="wtlb" class="easyui-validatebox" data-options=""></td>
						<td><label>问题严重程度:</label></td>
						<td ><input id="wtyzcd" name="wtyzcd" class="easyui-validatebox" data-options=""></td>
					</tr>
					<tr>
						<td><label>剩余风险可接受程度:</label></td>
						<td ><input id="syfxkjscd" name="syfxkjscd" class="easyui-validatebox" data-options=""></td>
						<td><label>动因性质:</label></td>
						<td ><input id="dyxz" name="dyxz" class="easyui-validatebox" data-options=""></td>
					</tr>
					 
					 
				</table>
			</form>
			<div id="dlg-btn">
				<button id="add" type="button" class="btn btn-primary" onclick="formSave('#fm', '#grid', '#dlg', '${ctx}/fnd/auditDefect/update');">
					<span class="glyphicon glyphicon-ok"></span> 保存
				</button>
				<button id="edit" type="button" class="btn btn-primary" onclick="$('#dlg').dialog('close');">
					<span class="glyphicon glyphicon-remove"></span> 取消
				</button>
			</div>
		</div>
		
</body>
</html>
